using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using OpenComposite.EII.Repository;

namespace OpenComposite.EII.Designer.Workflow.Forms
{
	public partial class FormSelectBObjectPath : Form
	{
		#region Initialization
		public FormSelectBObjectPath(BusinessObject bobject)
		{
			InitializeComponent();

			this.DialogResult = DialogResult.Cancel;

			bobjTree.VisibleDataTypes = "string";
			bobjTree.BusinessObject = bobject;
		}
		#endregion

		#region Public Members

		/// <summary>
		/// Gets the selected business object path.
		/// </summary>
		public string SelectedPath
		{
			get
			{
				if ( bobjTree.SelectedNode != null ) {
					return bobjTree.SelectedNode.FullPath;
				} else {
					return null;
				}
			}
		}

		#endregion

		#region Private Members

		#region Event Handlers
		private void tsbtnOK_Click(object sender, EventArgs e)
		{
			if ( this.bobjTree.SelectedNode == null ) {
				this.DialogResult = DialogResult.Cancel;
				MessageBox.Show("Please select a business object field.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
				return;
			}
			this.DialogResult = DialogResult.OK;
			this.Close();
		}

		private void tsbtnCancel_Click(object sender, EventArgs e)
		{
			this.DialogResult = DialogResult.Cancel;
			this.Close();
		}

		private void FormSelectBObjectPath_FormClosing(object sender, FormClosingEventArgs e)
		{

		}
		#endregion

		#endregion
	}
}